package com.noble.meether.ui.diamond.detail;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.noble.meether.R;
import com.noble.glamour.module.logic.baseui.ExBaseAdapter;
import com.noble.meether.ui.diamond.bean.Diamond;

import java.util.List;

/**
 * Created by Su on 2018/6/13.
 */
public class DiamondDetailAdapter extends ExBaseAdapter<Diamond> {

    public DiamondDetailAdapter(Context context, List<Diamond> data) {
        super(context, data);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        MyViewHolder holder;
        if (convertView == null) {
            convertView = inflate(R.layout.item_diamond_detail);
            holder = new MyViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (MyViewHolder) convertView.getTag();
        }
        final Diamond info = getItem(position);
        holder.item_title.setText(info.getTypePayName());
        holder.item_time.setText(info.getTimeCreate());
        holder.item_num.setText((info.getTypePay() > 0 ? "+" : "-") + (info.getDoPay() + info.getDoGive()));
        return convertView;
    }

    private class MyViewHolder {
        private TextView item_title, item_time, item_num;

        public MyViewHolder(View convertView) {
            initView(convertView);
        }

        private void initView(View convertView) {
            item_title = convertView.findViewById(R.id.item_title);
            item_time = convertView.findViewById(R.id.item_time);
            item_num = convertView.findViewById(R.id.item_num);
        }
    }
}
